import VueRouter from 'vue-router'
const router = new VueRouter({
  mode: 'history',
  routes: [
    {
      path: '/',
      component: resolve => require(['@/views/HomeView.vue'], resolve)
    },
    {
      path: '/login',
      component: resolve => require(['@/views/LoginView.vue'], resolve)
    },
    {
      path: '/error',
      name: 'Error',
      component: resolve => require(['@/views/ErrorView.vue'], resolve)
    },
    {
      path: '/item',
      name: 'Item',
      component: resolve => require(['@/views/ItemView.vue'], resolve)
    },
    {
      path: '/item/details',
      name: 'Details',
      component: resolve => require(['@/views/DetailsView.vue'], resolve)
    },
    {
      path: '/register',
      name: 'Register',
      component: resolve => require(['@/views/RegisterView.vue'], resolve)
    },
    {
      path: '/cart',
      name: 'Cart',
      component: resolve => require(['@/views/CartView.vue'], resolve),
      meta: { requireAuth: true }
    },
    {
      path: '/order',
      name: 'Order',
      component: resolve => require(['@/views/OrderView.vue'], resolve),
      meta: { requireAuth: true }
    },
    {
      path: '/order/confirm',
      name: 'ConfirmOrder',
      component: resolve => require(['@/views/ConfirmOrderView.vue'], resolve),
      meta: { requireAuth: true }
    },
    {
      path: '/member',
      name: 'Member',
      component: resolve => require(['@/views/MemberView.vue'], resolve),
      meta: { requireAuth: true }
    }
  ]
})
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
export default router
